PReLUFusion

对输入数组逐元素执行 PReLU 激活函数。对于每个元素,若小于等于 0,则乘以斜率参数 slope,否则保持原值。

\[\begin{split}\text{dst}_i = \begin{cases} \text{src}_i \cdot \text{slope}, & \text{if } \text{src}_i \le 0 \\ \text{src}_i, & \text{otherwise} \end{cases}\end{split}\]
输入:
  • src_data - 输入数据地址。

  • slope - PReLU 斜率参数。

  • start - 起始索引。

  • end - 结束索引。

  • core_mask - 核掩码(仅适用于共享存储版本)。

输出:
  • dst_data - 输出数据地址。

支持平台:

FT78NE MT7004

备注

  • FT78NE 支持fp, int8

  • MT7004 支持hp, fp

共享存储版本:

void fp_prelufusion_s(float *src_data, float *dst_data, float slope, int start, int end, int core_mask)
void hp_prelufusion_s(half *src_data, half *dst_data, half slope, int start, int end, int core_mask)
void i8_prelufusion_s(int8_t *src_data, int8_t *dst_data, float slope, int start, int end, int core_mask)

C调用示例:

 1#include <stdio.h>
 2#include <prelu_fusion.h>
 3
 4int main() {
 5    float *src = (float *)0xA0000000;        // 输入在DDR空间
 6    float *dst = (float *)0xC0000000;
 7    float slope = 0.25;
 8    int start = 0;
 9    int end = 999;
10    int core_mask = 0xff;
11
12    fp_prelufusion_s(src, dst, slope, start, end, core_mask);
13    return 0;
14}

私有存储版本:

void fp_prelufusion_p(float *src_data, float *dst_data, float slope, int start, int end)
void hp_prelufusion_p(half *src_data, half *dst_data, half slope, int start, int end)
void i8_prelufusion_p(int8_t *src_data, int8_t *dst_data, float slope, int start, int end)

C调用示例:

 1#include <stdio.h>
 2#include <prelu_fusion.h>
 3
 4int main() {
 5    float *src = (float *)0x10810000;        // 输入在L2空间
 6    float *dst = (float *)0x10820000;
 7    float slope = 0.25;
 8    int start = 0;
 9    int end = 999;
10
11    fp_prelufusion_p(src, dst, slope, start, end);
12    return 0;
13}